<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title></title>
  </head>
  <body>
    <div id="app">
      <div>{{ count }}</div>
      <div>{{ obj }}</div>
    </div>

    <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>

    <script>
      const { createApp, ref } = Vue;

      const app = createApp({
        setup() {
          const count = ref(0);
          // ref 既可以传入基础数据类型，还可以传入引用数据类型
          // 而且传入引用数据，是具有深层响应性
          const obj = ref({
            nested: { count: 0 },
            arr: ["foo", "bar"],
          });

          setTimeout(() => {
            count.value++;
            obj.value.nested.count++;
            obj.value.arr.push("baz");
          }, 3000);

          return {
            count,
            obj,
          };
        },
      });

      app.mount("#app");
    </script>
  </body>
</html>
